package com.googlecode.cannedbeans.generator.util;

import com.googlecode.cannedbeans.generator.core.exceptions.UnsupportedClassException;
import com.googlecode.cannedbeans.generator.model.Type;
import java.util.Map;

/**
 *
 * @author Kim
 */
public class TypeMapperImpl implements TypeMapper {

    /**
     * Typemapping, injected by spring.
     */
    private Map < Class, Type > classToTypeMapping;

    public Type getType(Class clazz) throws UnsupportedClassException{
        Type type = classToTypeMapping.get(clazz);
        if (type == null) {
            throw new UnsupportedClassException(clazz);
        } else {
            return type;
        }
    }

    public Map<Class, Type> getClassToTypeMapping() {
        return classToTypeMapping;
    }

    public void setClassToTypeMapping(Map<Class, Type> classToTypeMapping) {
        this.classToTypeMapping = classToTypeMapping;
    }

}
